package com.gonsin.ta.logic.node;

import com.gonsin.ta.logic.enums.ComponentTypeEnum;
import com.gonsin.ta.logic.enums.NodeTypeEnum;
import com.gonsin.ta.logic.parse.condition.Executable;
import com.gonsin.ta.logic.parse.serialize.SerializeContext;
import com.gonsin.ta.logic.parse.serialize.NodeSerial;
import com.gonsin.ta.logic.parse.serialize.TaDeserializable;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public abstract class Node implements Executable, Cloneable {

    private String nodeId;

    private ComponentTypeEnum componentType;

    public Node(String nodeId) {
        this.nodeId = nodeId;
        this.componentType = ComponentTypeEnum.NODE;
    }

    public abstract NodeTypeEnum getNodeType();

    public String getNodeId() {
        return nodeId;
    }

    public ComponentTypeEnum getComponentType() {
        return componentType;
    }


    @Override
    public TaDeserializable toSerializable(SerializeContext serializeContext) {
        NodeSerial serial = new NodeSerial();
        serial.setNodeId(getNodeId());
        serial.setComponentType(getComponentType());
        serial.setNodeType(getNodeType());
        return serial;
    }
}
